home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7490 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: diku.dk!null
  2. From: null@diku.dk (Niels Ull Jacobsen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: fast copy
  5. Date: 23 Feb 1996 16:13:12 GMT
  6. Organization: Department of Computer Science, U of Copenhagen
  7. Sender: null@tyr.diku.dk
  8. Message-ID: <4gkp2o$52j@odin.diku.dk>
  9. References: <4ftp17$go3@news1.usa.pipeline.com>
  10. NNTP-Posting-Host: odin.diku.dk
  11. X-Newsreader: NN version 6.5.0 #13
  12.  
  13. grantp@usa.pipeline.com(Pete) writes:
  14.  
  15. >On Feb 12, 1996 22:05:49 in article <fast copy>, 'cbenoit@mail.imaginet.fr
  16. >(Christophe Benoit)' wrote: 
  17. >>Do you know the best method (run-time performance) to copy a file ? 
  18. >I assume you mean best in terms of time.   
  19. >1.  Open the file in binary mode. 
  20. >2.  Determine its size 
  21. >3.  Allocate a buffer large enough for the entire file. 
  22. >4.  Read it in in one fread. 
  23. >5.  Open output file and fwrite entire buffer in one whoosh. 
  24. >6.  Close both. 
  25.  
  26. Or, alternatively:
  27. 1. Call the copyfile command of your target OS.
  28. Most OS's have them (Win16: LZCopy, Win32: CopyFile, ...)
  29.  
  30.  
  31. >You can beat this using assembler, but such gains are usually 
  32. >insignificant.  If the file is too large to fit into one buffer, split 
  33. >it into as large blocks as possible to reduce the number of 
  34. >calls to IO routines. 
  35. >-- 
  36. >Pete Grant 
  37. >Kalevi, Inc. 
  38. >Software Engineering & development
  39. -- 
  40.    Niels Ull Jacobsen, Dep. of CS, U of Copenhagen (null@diku.dk)
  41.    Roenne Alle 3 st.th, 2860 Soeborg, Denmark, tel. +45 39 66 39 86
  42.  
  43.